package TOP_Version1;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLRecoverableException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Top_AdminSetVO {
	static Top_JDBC_SQL topsql = new Top_JDBC_SQL();
	static Top_AdminVO av = new Top_AdminVO();
	static StringBuilder sb = new StringBuilder();
	static Scanner sc = new  Scanner(System.in);
	static Connection conn = null;
	static PreparedStatement pstmt = null;
	static ResultSet rs = null;
	static boolean b = true;
	static String add = null;
	static String addv = null;
	// static String logId = Top_LoginMain.logIdVO;
	
	//  	public List<J03_MemberVO> selectMember() {
/*	Connection conn = null;
	PreparedStatement pstmt = null;
	ResultSet rs = null;
	List<J03_MemberVO> result = new ArrayList<>();			// 동적배열
	
	try {
			conn = openDatabase();
			pstmt = conn.prepareStatement(selectSQL);
			rs = pstmt.executeQuery();
			while( rs.next() ) {
				J03_MemberVO m = new J03_MemberVO();
				m.setMno( rs.getString("mno") );
				m.setUserid( rs.getString("userid") );
				m.setPasswd( rs.getString("passwd") );
				m.setName( rs.getString("name") );
				m.setEmail( rs.getString("email") );
				m.setRegdate( rs.getString("regdate") );
				result.add( m );
									
			}
			
			
	} catch ( Exception ex ) {
		ex.printStackTrace();
		
	}finally {
		closeDatabase(conn, pstmt, rs);
		
	}
	
	return result;
}*/
	
	protected static List< Top_AdminVO > setVOAdmin(String logId) {
		
		while ( b ) {
			// System.out.print("수정하실 관리자의 아이디를 입력하세요 : ");
			add = logId;
			ResultSet rs = null;
			try {
				conn = Top_JDBC_Connection.openDataBase();
				pstmt = conn.prepareStatement(topsql.AdminSelectAllSQL);
				pstmt.setString( 1, add );		// 검색?
				rs = pstmt.executeQuery();
				List<Top_AdminVO> result = new ArrayList<>();
				if ( rs.next() ) {
					do {			
						
						av.setAdmin_tr( rs.getString( "ADMIN_TR" ) );
						av.setAdmin_id( rs.getString( "ADMIN_ID" ) );
						av.setAdmin_name( rs.getString( "ADMIN_NAME" ) );
						av.setAdmin_pw( rs.getString( "ADMIN_PW" ) );
						av.setAdmin_tel( rs.getString( "ADMIN_TEL" ) );
						av.setReg_date( rs.getString( "REG_DATE" ) );
						result.add( av );
						
					} while ( rs.next() );
				// System.out.println( av.toString() );
				b = false;
				} else { System.err.println("아이디를 잘못입력하셨습니다. 다시 입력해 주세요"); }
			} catch ( SQLRecoverableException se ) {
				System.err.println("데이터베이스 연결에 실패했습니다. 네트워크를 확인하세요. 시스템을 종료합니다.");
				System.exit(0);
			} catch ( Exception e ) {
				e.printStackTrace();
			} finally {
				Top_JDBC_Connection.closeDataBase(conn, pstmt, rs);
			}
				
		}
		return null;
	}
}
